<template>
  <div>
  <h2>优惠劵列表</h2>
  <hr>
  <input type="button" value="新增优惠劵" @click="YHJAdd">
  <table border="1">
    <tr>
      <td>优惠劵名称</td>
      <td>优惠劵类型</td>
      <td>优惠劵面值</td>
      <td>优惠劵消费</td>
      <td>优惠劵有效期</td>
      <td>优惠劵创建时间</td>
      <td>状态</td>
      <td>操作</td>
    </tr>
    <tr v-for="item in list">
      <td>{{item.yName}}</td>
      <td>{{item.yType}}</td>
      <td>{{item.ymz}}</td>
      <td>{{item.yxf}}</td>
      <td>{{item.yxq}}</td>
      <td>{{item.ycTume.substr(0,10)}}</td>
      <td>{{ item.yzt == '1' ? '正常' : '已过期' }}</td>
        <td>
          <input type="button" v-if="item.yzt == '1'" value="已过期" />
          <input type="button" v-else value="正常" />
        </td>
    </tr>
  </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import axios from 'axios';

const router = useRouter();
const route = useRoute();

let data: any = reactive({
  list:[]
});

let {list } = toRefs(data);

onMounted(() => {
  YHJShow()
})
//优惠劵列表
function YHJShow()
{
  axios({
    url:'https://localhost:7127/api/YHJ/YHJShow',
    method:'get'
  })
  .then(res=>{
    list.value=res.data.data
  })
  .catch(err=>{
    console.log(err)
  })
}









function YHJAdd(){
  router.push('/YHJAdd')
}


</script>

<style scoped>

</style>